<% admin_breadcrumb(link_to plural_resource_name(Spree::Order), spree.admin_orders_path) %>
<% admin_breadcrumb(link_to "##{@order.number}", spree.edit_admin_order_path(@order)) %>
<% admin_breadcrumb(Spree.t(:cancel_inventory)) %>


<table class="stock-contents index">
  <colgroup>
    <col style="width: 10%;" />
    <col style="width: 35%;" />
    <col style="width: 10%;" />
    <col style="width: 15%;" />
    <col style="width: 20%;" />
    <col style="width: 10%;" />
  </colgroup>

  <thead>
    <th colspan="2"><%= Spree::LineItem.human_attribute_name(:description) %></th>
    <th><%= Spree::OrderCancellations.human_attribute_name(:quantity) %></th>
    <th><%= Spree::OrderCancellations.human_attribute_name(:state) %></th>
    <th><%= Spree::OrderCancellations.human_attribute_name(:shipment) %></th>
    <th><%= Spree::OrderCancellations.human_attribute_name(:cancel) %></th>
  </thead>

  <tbody>
    <%= form_for :inventory_units, url: short_ship_admin_order_cancellations_path(@order) do |f| %>
      <% @inventory_units.each do |inventory_unit| %>
        <tr class="inventory-unit">
          <td class="inventory-unit-image">
            <%= image_tag inventory_unit.variant.display_image.attachment(:mini) %>
          </td>
          <td class="inventory-unit-name">
            <%= inventory_unit.variant.product.name %><br><%= "(" + variant_options(inventory_unit.variant) + ")" unless inventory_unit.variant.option_values.empty? %>
            <% if inventory_unit.variant.sku.present? %>
              <strong><%= Spree::Variant.human_attribute_name(:sku) %>:</strong> <%= inventory_unit.variant.sku %>
            <% end %>
          </td>
          <td class="inventory-unit-quantity align-center">1</td>
          <td class="inventory-unit-state align-center"><%= inventory_unit.state %></td>
          <td class="inventory-unit-shipment align-center"><%= inventory_unit.shipment.number %></td>
          <td class="inventory-unit-cancel align-center">
            <%= check_box_tag 'inventory_unit_ids[]', inventory_unit.id %>
          </td>
        </tr>
      <% end %>
      <tr class="submit-cancellation">
        <td colspan="6" class="align-center">
          <%= f.submit Spree.t(:cancel_inventory) %>
        </td>
      </tr>
    <% end %>
  </tbody>
</table>
